<!DOCTYPE html>
<html lang="zh-CN">
  <head>
	  <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'添加用户', styles:'bootstrap,font-awesome,animate,style,dtvalidate'}){%>
	  <style type="text/css">
		  body{padding-top:10px;}
	  </style>
	  <%}%>
  </head>
  <body>
	<!-- START 内容部分 -->
	<div class="container">
		<form class="form-horizontal" id="info-form" method="post">
			<div class="form-group">
				<label class="col-sm-2 control-label text-right">角色名称</label>
				<div class="col-sm-6">
					<input type="text" id="roleName" name="roleName" class="form-control" valid="r" validTitle="角色名称" validInfoArea="roleName_info_area" />
				</div>
				<div class="col-sm-4"><p class="help-block" id="roleName_info_area"></p></div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label text-right">角色描述</label>
				<div class="col-sm-6">
					<input type="text" id="roleDesc" name="roleDesc" class="form-control" valid="r" validTitle="角色描述" validInfoArea="roleDesc_info_area" />
				</div>
				<div class="col-sm-4"><p class="help-block" id="roleDesc_info_area"></p></div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label text-right">启用标志</label>
				<div class="col-sm-6">
					<label class="radio-inline">
					  <input type="radio" name="enabled" value="1" valid="r" validTitle="启用标志" validInfoArea="enabled_info_area" checked/> 启用
					</label>
					<label class="radio-inline">
					  <input type="radio" name="enabled" value="0" valid="r" validTitle="启用标志" validInfoArea="enabled_info_area"/> 禁用
					</label>
				</div>
				<div class="col-sm-4"><p class="help-block" id="enabled_info_area"></p></div>
			</div>
			
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="button" class="save-btn btn btn-primary">
						<i class="fa fa-save"></i> 提交
					</button>
				</div>
			</div>
		</form>
	</div>
	<!-- END 内容部分 -->

	<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,dtvalidate,dtvalidate-lang-zh_cn'}){}%>
	<script>
	var cvalidator;
	$(function(){
		//初始化验证器
		cvalidator = $.fn.dlshouwen.validator.init($('#info-form'));
		
		//提交表单
		$('.save-btn').on('click',function(){
			if(!cvalidator.validResult()){
				$.fn.dlshouwen.validator.tools.toast('验证失败！', 'error', 2000);
				return;
			}
			
			//数据提交
			$.post('${ctxPath}/power/role/save.do',$('#info-form').serialize(),function(data){
				if( data.ok ){
					parent.layer.msg(data.msg,{icon:1,time:2000,shade: [0.8, '#393D49']}, function(){
						parent.$powerroletable.bootstrapTable('refresh');
						parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭弹窗
					});
				}else{
					parent.layer.msg(data.msg,{icon: 0,time:1500,shade: [0.8, '#393D49']});
				}
			});
		});
    });
    </script>
  </body>
</html>